package com.gee.spring.boot.rpf.client;

import com.gee.spring.boot.rpf.controller.fico.RequestWrapper;
import com.gee.spring.boot.rpf.entity.ClientReqInitializer;
import com.gee.thread.flow.executor.ExecuteContext;

/**
 * desc:
 * @author gee wrote on  2021-02-04 10:39:34
 */
public class RequestInitializerProcessor {


    public void reqInitProcess(String preWorkId, ExecuteContext<RequestWrapper> executeContext,
                               ClientReqInitializer clientReqInitializer) throws Exception{
        Class<?> targetReqClass = Class.forName(clientReqInitializer.getTargetReqClass());
        Object instance = targetReqClass.newInstance();
        /*Integer paramSourceType = clientReqInitializer.getParamSourceType();
        if (paramSourceType == 1){
            JSONObject request = executeContext.getVariable().getRequest();
            Class<?> targetFieldType = CommonUtil.getJavaType(clientReqInitializer.getTargetReqFieldType());
            Field field = ReflectionUtils.findField(targetReqClass, clientReqInitializer.getTargetReqFieldName());
            if (field != null){
                Object fieldValue = getFromRequest(request, targetFieldType);
                ReflectionUtils.makeAccessible(field);
                ReflectionUtils.setField(field, instance, fieldValue);
            }
        }else if (paramSourceType == 2){

        }else {

        }*/
    }
}
